<?php

namespace Xin\ChatGPT;

use Xin\Capsule\Manager;
use Xin\ChatGPT\Channels\Moonshot;
use Xin\ChatGPT\Channels\Zhipu;
use Xin\ChatGPT\Contracts\Channel;
use Xin\ChatGPT\Contracts\Factory;

class ChatGPTManager extends Manager implements Factory
{
    /**
     * 默认的驱动键名
     */
    public const DEFAULT_DRIVER_KEY = 'channel';

    /**
     * 默认的驱动类型
     */
    public const DEFAULT_DRIVER_VALUE = 'default';

    /**
     * 驱动的列表键名
     */
    public const DRIVER_CONFIG_KEY = 'channels';

    /**
     * @inerhitDoc
     */
    public function channel(string $name = null): Channel
    {
        return $this->driver($name);
    }

    /**
     * @param string $name
     * @param array $config
     * @return Channel
     * @link https://platform.moonshot.cn/docs/api-reference#%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B
     */
    protected function createMoonshotDriver($name, array $config): Channel
    {
        return new Moonshot\Channel($config);
    }

    /**
     * @param string $name
     * @param array $config
     * @return Channel
     * @link https://open.bigmodel.cn/dev/api
     */
    protected function createZhipuDriver($name, array $config): Channel
    {
        return new Zhipu\Channel($config);
    }
}
